package com.api.zszsj2.util;

import com.alibaba.fastjson.JSONObject;

import java.util.HashMap;
import java.util.Map;

public class ApiResult{
    private String status;
    private String code = "";
    private String message;
    private HashMap data;

    public String getStatus() {
        return this.status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getCode() {
        return this.code;
    }

    public void setCode(String errorCode) {
        this.code = errorCode;
    }

    public String getMessage() {
        return this.message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public HashMap getData() {
        return this.data;
    }

    public void setData(HashMap data) {
        this.data = data;
    }

    public void putData(Object key, Object value) {
        if(this.data==null)
            this.data = new HashMap();
        this.data.put(key,value);
    }

    public String OutputString(){
        HashMap result = new HashMap<>();
        if(status.equalsIgnoreCase("success"))
            result.put("success","1");
        else
            result.put("success","0");

        result.put("code",code);
        result.put("message",message);
        result.put("data",data);
        return JSONObject.toJSONString(result);
    }
}